package com.readygo.boot_test.entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.*;
import java.util.Collection;

@SqlResultSetMapping(
        name="findUserCourseByUserIdMapping",
        classes = {
                @ConstructorResult(
                        targetClass = com.readygo.boot_test.vo.UserCourse.class,
                        columns = {
                                @ColumnResult(name="username"),
                                @ColumnResult(name="course_name")
                        }
                )
        }
)
@NamedNativeQuery(name="User.findUserCourseByUserId", query = "SELECT username, course_Name FROM User u INNER JOIN Course c ON u.user_Id = c.user_Id WHERE u.user_Id = :userId", resultSetMapping = "findUserCourseByUserIdMapping")
@Entity
public class User {

    @Id
    private Integer userId;

    private String username;

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
